package com.jxm.comparable;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2022/6/9 9:20
 * @Version: 1.0
 */
public class TestComparable {

    public static void main(String[] args) {
        Student student1 = new Student();
        student1.setUserName("zhangsan");
        student1.setAge(25);
        Student student2 = new Student();
        student2.setUserName("lisi");
        student2.setAge(20);

        Comparable max = getMax(student1, student2);
        System.out.println(max);

    }

    public static Comparable getMax(Comparable c1,Comparable c2){
        int i = c1.compareTo(c2);
        if(i >= 0){
            return c1;
        }else{
           return c2;
        }
    }
}
